package com.quanyan.place.web;

import com.quanyan.api.APIResponse;
import com.quanyan.place.entity.apireq.ReqPlaceMessageVo;
import com.quanyan.place.entity.apireq.ReqPlaceOrderInfo;
import com.quanyan.place.wrapper.PlaceMessageWrapper;
import com.quanyan.place.wrapper.PlaceWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * Created by liuyaoxin on 2016/6/16.
 */

@RestController
@RequestMapping("/admin/api/place/noticeMessage")
public class PlaceMessageController {

    private Logger logger = LoggerFactory.getLogger(PlaceMessageController.class);

    @Autowired
    PlaceWrapper placeWrapper;

    @Autowired
    PlaceMessageWrapper placeMessageWrapper;

    /**
     * 添加短信相关的数据
     * @param reqPlaceMessageVo
     * @return
     */
    @RequestMapping(value = "/insertMessageData", method = RequestMethod.POST)
    public APIResponse<?> insertMessageData(@RequestBody @Valid ReqPlaceMessageVo reqPlaceMessageVo, BindingResult bindingResult)  {
             return placeWrapper.insertMessageData(reqPlaceMessageVo);
        }

    /**
     * 查询短信相关的数据
     * @param  placeId
     * @return
     * @throws Exception
     */
    @RequestMapping(value="/getMessageDataByPlaceId",method = RequestMethod.GET)
    public APIResponse<?> getMessageDataByPlaceId(@RequestParam (value="placeId") Integer placeId){
        return placeWrapper.getMessageDataByPlaceId(placeId);
    }

    /**
     * 添加短信相关的数据
     * @param reqPlaceMessageVo
     * @return
     */
    @RequestMapping(value = "/deleteMessageData", method = RequestMethod.POST)
    public APIResponse<?> deleteMessageData(@RequestBody @Valid ReqPlaceMessageVo reqPlaceMessageVo, BindingResult bindingResult)  {
        return placeWrapper.deleteMessageData(reqPlaceMessageVo);
    }


    /**
     * 推广下发短信
     * @param reqPlaceMessageVo
     * @return
     */
    @RequestMapping(value = "/sendPromotionMessageData", method = RequestMethod.POST)
    public APIResponse<?> sendPromotionMessageData(@RequestBody @Valid ReqPlaceMessageVo reqPlaceMessageVo, BindingResult bindingResult)  {
        return placeMessageWrapper.sendPromotionMessageData(reqPlaceMessageVo);
    }


    /**
     * 推广下发短信支付
     * @param reqPlaceOrderInfo
     * @return
     */
    @RequestMapping(value = "/promotionPay", method = RequestMethod.POST)
    public APIResponse<?> promotionPay(@RequestBody  ReqPlaceOrderInfo reqPlaceOrderInfo, BindingResult bindingResult)  {
        return placeMessageWrapper.promotionSave(reqPlaceOrderInfo);
    }

}
